package com.yeyaomai.dksns.flowis.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import com.yeyaomai.dksns.flowis.dao.VisitAreaDao;
import com.yeyaomai.dksns.flowis.domain.VisitArea;
import com.yeyaomai.dksns.flowis.page.PageImplResult;
import com.yeyaomai.dksns.flowis.page.PageRequestOrder;
import com.yeyaomai.dksns.flowis.page.SplitConstant;
import com.yeyaomai.dksns.flowis.service.VisitAreaService;

/**
 * 地域分析
 * 
 * @author xiaqin
 * 
 */
@Service
public class VisitAreaServiceImpl implements VisitAreaService {

	@Resource
	private VisitAreaDao visitAreaDao;

	@Override
	public VisitArea getVisitAreaById(long id) {

		return visitAreaDao.getVisitAreaById(id);
	}

	@Override
	public List<VisitArea> getVisitAreaByDay(Map<String, Object> map) {

		return visitAreaDao.getVisitAreaByDay(map);
	}

	@Override
	public Page<VisitArea> getDataPage(Map<String, Object> map,
			Integer currentpage) {
		long visitAreaCount = visitAreaDao.getVisitAreaCount(map);
		PageRequestOrder request = new PageRequestOrder(currentpage,
				SplitConstant.PAGE_SIZE);
		List<VisitArea> visitAreaList = new ArrayList<VisitArea>();
		map.put("startNumber", request.start());
		map.put("endNumber", request.end());
		visitAreaList = visitAreaDao.getVisitAreaByDay(map);
		Page<VisitArea> result = new PageImplResult<VisitArea>(visitAreaList,
				request, visitAreaCount);
		return result;
	}
	
	public VisitArea getVisitAreaByTime(String fromDate,String toDate)
	{
		return visitAreaDao.getVisitAreaByTime(fromDate, toDate);
	}

	public List<VisitArea> getVisitAreaByProvince(Map<String,Object> map)
	{
		return visitAreaDao.getVisitAreaByProvince(map);
	}
}
